package tg.app.opticket.virtual;

import java.rmi.RemoteException;

import psdi.app.common.virtual.ChangeStatusSet;
import psdi.mbo.Mbo;
import psdi.mbo.MboRemote;
import psdi.mbo.MboServerInterface;
import psdi.mbo.MboSet;
import psdi.mbo.MboSetRemote;
import psdi.mbo.NonPersistentMboSetRemote;
import psdi.mbo.SqlFormat;
import psdi.util.MXException;
import tg.app.opticket.OpTicket;

/***
 * 
 * @author pzx
 *
 */
public class OpticketChangeStatusSet extends ChangeStatusSet implements
		NonPersistentMboSetRemote {

	public OpticketChangeStatusSet(MboServerInterface ms) throws MXException,
			RemoteException {
		super(ms);
	}

	@Override
	protected MboSetRemote getMboIntoSet(MboRemote mboRemote) throws MXException,
			RemoteException {
		MboSetRemote changeFVSet = getMboServer().getMboSet(mboRemote.getName(), getUserInfo());
		String sql = "opticketid=:opticketid";
		SqlFormat sqf = new SqlFormat(mboRemote, sql);
		changeFVSet.setWhere(sqf.format());
		return changeFVSet;
	}

	@Override
	protected Mbo getMboInstance(MboSet ms) throws MXException,
			RemoteException {
		return new OpticketChangeStatus(ms);
	}

	protected void changeMboStatus(MboRemote mboRemote, MboRemote param)
			throws MXException, RemoteException {
		if(mboRemote instanceof OpTicket){
			OpTicket curopticket = (OpTicket) mboRemote;
			String status=param.getString("status");
			curopticket.changeStatus(status,param.getDate("statdate"), param.getString("memo"));
			curopticket.setValue("statusdate", param.getDate("statdate"),11L);
		}
		
		
	}

}
